package xrz.cuanbao.services;

import org.simple.eventbus.EventBus;

import xrz.cuanbao.utils.ThreadPoolUtils;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class RegTimeService extends Service {

	private int m_Miao;

	@Override
	public IBinder onBind(Intent arg0) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		ThreadPoolUtils.newInstant().submit(new TimeRunnable());
		m_Miao = 0;
		return START_STICKY;  
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	private class TimeRunnable implements Runnable {

		@Override
		public void run() {
			while (m_Miao < 60) {
				m_Miao++;
				EventBus.getDefault().post(m_Miao, "regTime");
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
				}
			}
			RegTimeUtils.clear(RegTimeService.this);
		}

	}
}
